import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

// 扩展 RouteMeta 接口
declare module "vue-router" {
  interface RouteMeta {
    id?: string | number;
    title?: string;
    icon?: string;
    hide?: boolean;
  }
}

export const localRouter: Array<RouteRecordRaw> = [
  {
    path: "/welcome",
    name: "welcome",
    component: () => import("@/views/dashboard/index.vue"),
    meta: {
      title: "首页",
      icon: "HomeFilled",
      hide: false,
    },
  },
  {
    path: "/WatchDetails",
    name: "WatchDetails",
    component: () =>
      import("@/views/totalManage/watchTotal/components/watchDetails.vue"),
    meta: {
      title: "观看详情",
      icon: "",
      hide: false,
    },
  },
  {
    path: "/BrowseDetails",
    name: "BrowseDetails",
    component: () =>
      import("@/views/totalManage/browseTotal/components/browseDetails.vue"),
    meta: {
      title: "资讯详情",
      icon: "",
      hide: false,
    },
  },
  {
    path: "/TrainDetail",
    name: "TrainDetail",
    component: () =>
      import("@/views/trainManage/trainList/components/detail.vue"),
    meta: {
      title: "xx详情",
      icon: "",
      hide: false,
    },
  },
];

const routers: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/Login.vue"),
    meta: {
      title: "登录",
    },
  },
  {
    path: "/",
    name: "main",
    component: () => import("@/views/layout/index.vue"),
    redirect: "/welcome",
    meta: {
      title: "首页",
      icon: "HomeFilled",
    },
    children: [...localRouter],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: routers,
});

export default router;
